﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace YJKArch.DimensionModule
{
	public partial class DlgCoordinateDim : System.Windows.Forms.Form
	{
		public DlgCoordinateDim()
		{
			this.InitializeComponent();
		}

		[DllImport("user32.dll", EntryPoint = "SendMessageA")]
		public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);

		private void CoordinateForm_MouseLeave(object sender, EventArgs e)
		{
			if (!base.ClientRectangle.Contains(base.PointToClient(Cursor.Position)))
			{
				int wMsg = 7;
				DlgCoordinateDim.SendMessage(CmdCoordinateDim._hWndRevit.Handle, wMsg, IntPtr.Zero, IntPtr.Zero);
			}
			else
			{
				base.Focus();
			}
			this.ArrowType = this.cboArrowType.SelectedItem.ToString();
			this.FontType = this.cboFontType.SelectedItem.ToString();
			this.TagPrecision = this.cboTagPrecision.SelectedItem.ToString();
			this.TXTFixAngle = this.txtFixAngle.Text;
		}

		private void cboArrowType_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.ArrowType = this.cboArrowType.SelectedItem.ToString();
		}

		private void cboFontType_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.FontType = this.cboFontType.SelectedItem.ToString();
		}

		private void cboTagPrecision_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.TagPrecision = this.cboTagPrecision.SelectedItem.ToString();
		}

		private void rdobtnMeasurePoint_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdobtnMeasurePoint.Checked)
			{
				this.ischeckrdo = true;
			}
		}

		private void rdobtnConstruct_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdobtnConstruct.Checked)
			{
				this.ischeckrdo = false;
			}
		}

		private void ckbFixAngle_CheckedChanged(object sender, EventArgs e)
		{
			if (this.ckbFixAngle.Checked)
			{
				this.isFixangle = true;
				return;
			}
			this.isFixangle = false;
		}

		private void cboFixAngle_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.Fixangle = this.cboFixAngle.SelectedItem.ToString();
		}

		private void cboFixAngle_KeyPress(object sender, KeyPressEventArgs e)
		{
			Helper.TxtSetNum(sender, e);
		}

		private void txtFixAngle_TextChanged(object sender, EventArgs e)
		{
			this.TXTFixAngle = this.txtFixAngle.Text;
			if (this.txtFixAngle.Text == "")
			{
				this.TXTFixAngle = "0";
			}
		}

		private void DlgCoordinateDim_Load(object sender, EventArgs e)
		{
			Helper.AddCombItems(DimDate.FontFamily, this.cboFontType);
			Helper.AddCombItems(DimDate.ArrowType, this.cboArrowType);
			if (this.cboTagPrecision.Items.Count > 0)
			{
				this.cboTagPrecision.SelectedIndex = 0;
			}
			if (this.cboFixAngle.Items.Count > 0)
			{
				this.cboFixAngle.SelectedIndex = 0;
			}
			this.ArrowType = this.cboArrowType.SelectedItem.ToString();
			this.FontType = this.cboFontType.SelectedItem.ToString();
			this.TagPrecision = this.cboTagPrecision.SelectedItem.ToString();
			this.rdobtnMeasurePoint.Checked = true;
			this.isFixangle = false;
			this.TXTFixAngle = this.txtFixAngle.Text;
		}

		private void txtFixAngle_KeyPress(object sender, KeyPressEventArgs e)
		{
			Helper.TxtSet(sender, e);
		}

		private void cboFixAngle_TextChanged(object sender, EventArgs e)
		{
			this.Fixangle = this.cboFixAngle.Text;
		}

		public string ArrowType;

		public string FontType;

		public string TagPrecision;

		public bool ischeckrdo = true;

		public bool isFixangle;

		public string Fixangle;

		public string TXTFixAngle;
	}
}
